package com.example.service;

import com.alipay.sofa.runtime.api.aware.ClientFactoryAware;
import com.alipay.sofa.runtime.api.client.ClientFactory;
import com.alipay.sofa.runtime.api.client.ReferenceClient;
import com.alipay.sofa.runtime.api.client.param.ReferenceParam;

//API 方式引用服务
public class JvmServiceConsumer implements ClientFactoryAware {
	private ClientFactory clientFactory;

	public void init() {
		ReferenceClient referenceClient = clientFactory.getClient(ReferenceClient.class);
		ReferenceParam<UserService> referenceParam = new ReferenceParam<>();
		referenceParam.setInterfaceType(UserService.class);
		referenceParam.setUniqueId("serviceClientImpl");

		UserService sampleJvmServiceClientImpl = referenceClient.reference(referenceParam);
		sampleJvmServiceClientImpl.profile("--cst--");
	}

	@Override
	public void setClientFactory(ClientFactory clientFactory) {
		System.err.println("--JvmServiceConsumer--invoke---");
		this.clientFactory = clientFactory;
	}

}
